﻿Imports Microsoft.Win32

Namespace helper
    ''' <summary>
    ''' provides method due with registry
    ''' </summary>
    ''' <remarks></remarks>
    Public NotInheritable Class RegistryHelper

        ''' <summary>
        ''' get MimeType by fileInfo
        ''' </summary>
        ''' <param name="fileInfo"></param>
        ''' <returns>return mimeType</returns>
        ''' <remarks></remarks>
        Public Shared Function GetMimeType(ByVal fileInfo As IO.FileInfo) As String
            Dim mimeType As String = "application/unknown"

            Dim regKey As RegistryKey = Registry.ClassesRoot.OpenSubKey(fileInfo.Extension.ToLower())

            If regKey IsNot Nothing Then
                Dim contentType As Object = regKey.GetValue("Content Type")

                If contentType IsNot Nothing Then
                    mimeType = contentType.ToString()
                End If
            End If

            Return mimeType
        End Function
    End Class
End Namespace


